import { defineStore } from 'pinia'
import type { TSafeTopArea } from '@/types/common'

type TCommonStore = {
  platform: typeof __UNI_PLATFORM__
  safeTopArea: TSafeTopArea
}

export const useCommonStore = defineStore('commonStore', {
  state: (): TCommonStore => ({
    platform: 'h5',
    safeTopArea: {
      statusBarHeight: 0,
      menuBtnHeight: 0,
    },
  }),
  actions: {
    setSafeTopArea(val: TSafeTopArea) {
      this.safeTopArea = val
    },
    setPlatform(platform: string) {
      this.platform = platform
    },
  },
  persist: {
    storage: localStorage,
  },
})
